package com.zhu.SupermarketInventoryManagement.controller;


import com.zhu.SupermarketInventoryManagement.model.QO.GoodsQO;
import com.zhu.SupermarketInventoryManagement.model.ResultCommon;
import com.zhu.SupermarketInventoryManagement.service.GoodsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/goods/api")
public class GoodsListApiController {

    @Resource
    GoodsService goodsService;

    @PostMapping("/list")
    public ResultCommon list(@RequestBody GoodsQO goodsQO) {
        return goodsService.list(goodsQO);
    }

    @PostMapping("/record")
    public ResultCommon record(@RequestBody GoodsQO goodsQO) {
        return goodsService.record(goodsQO);
    }

    @PostMapping("/update")
    public ResultCommon update(@RequestBody GoodsQO goodsQO) {
//        System.out.println("GoodsListApiController 获取的数据: " + goodsQO);
        ResultCommon resultCommon = goodsService.update(goodsQO);
//        System.out.println("GoodsListApiController 状态码: " + resultCommon);
        return resultCommon;
    }

    @PostMapping("/delete/{id}")
    public ResultCommon delete(@PathVariable String id) {
        return goodsService.delete(id);
    }

    @PostMapping("/add")
    public ResultCommon add(@RequestBody GoodsQO goodsQO) {
        return goodsService.add(goodsQO);
    }

}
